package cn.com.jslh.boarpro.util.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.jslh.boarpro.R;
import cn.com.jslh.boarpro.main.entity.WarnResultBody;
import cn.com.jslh.boarpro.main.entity.WarnResultEntity;
import cn.com.jslh.boarpro.main.entity.WarnResultHead;

/**
 * Created by lenovo on 2018/3/23.
 */

public class WarnResultAdapter extends BaseRecycleAdapter<WarnResultBody> {
    private int width;
    private List<String> dwidth;

    public List<String> getDwidth() {
        return dwidth;
    }

    public void setDwidth(List<String> dwidth) {
        this.dwidth = dwidth;
    }

    public WarnResultAdapter(int layoutResId, int width) {
        super(layoutResId);
        this.width=width;
    }

    @Override
    protected void convert(BaseViewHolder helper, WarnResultBody item) {
        LinearLayout layout=helper.getView(R.id.layout_warn_result);
        layout.setTag(helper.getAdapterPosition());
        Integer tag= (Integer) layout.getTag();
        if(item!=null&&tag==helper.getAdapterPosition()){
            List<String> title=item.getRow();
            helper.setText(R.id.tv_bh_item,title.get(0));
            helper.setText(R.id.tv_eh_item,title.get(1));
            helper.setText(R.id.tv_pz_item,title.get(2));
            helper.setText(R.id.tv_dn_item,title.get(3));
            helper.setText(R.id.tv_tc1_item,title.get(4));
            helper.setText(R.id.tv_tc2_item,title.get(5));
            helper.setText(R.id.tv_tc3_item,title.get(6));

//            for(int i=0;i<title.size();i++){
//                TextView textView=new TextView(mContext);
//                textView.setTextSize(14);
//                textView.setText(title.get(i));
//                textView.setGravity(Gravity.CENTER);
//                int mWidth= (int) (Double.parseDouble(getDwidth().get(i)) * (width-100));
//                textView.setWidth(mWidth);
//                layout.addView(textView);
//            }


            if(helper.getAdapterPosition()%2==0){
                layout.setBackgroundColor(mContext.getResources().getColor(R.color.white));
            }else {
                layout.setBackgroundColor(mContext.getResources().getColor(R.color.diver_line));
            }
        }

    }





}
